/*
 * inotify-sync - a simple file synchronizer and file system watcher
 * Copyright (C) 2010-2011, inotify-sync developers and inotify-sync contributors
 * Copyright (C) 2010-2011, Cohesion Network Security Studio
 *
 * inotify-sync is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * inotify-sync is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with inotify-sync; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

/*
 * FILE:		Converter.h
 * USAGE:		---
 * DESCRIPTION:		---
 * OPTIONS:		---
 * REQUIREMENTS:	---
 * BUGS:		---
 * NOTES:		---
 * AUTHOR:		LI Yiwei (mail:leeyiw@gmail.com)
 * COMPANY:		---
 * VERSION:		1.0
 * CREATED:		Sun Oct 16 12:06:52 CST 2011
 * REVISION:		---
 */


#ifndef CONVERTER
#define CONVERTER

#include <sstream>

using namespace std;

class Converter
{
public:
	Converter(){}
	virtual ~Converter(){}
	
	template<class out_type,class in_value>
	out_type conv(const in_value& t)
	{
		sstream<<t;//向流中传值
		out_type result;//这里存储转换结果
		sstream>>result;//向result中写入值
		//清除流中的东西
		sstream.str("");
		sstream.clear();
		return result;
	}
protected:
private:
	stringstream sstream;
};
#endif
